package ru.batrdmi.svnplugin.actions;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import ru.batrdmi.svnplugin.SVNRevisionGraph;

public class EnableExtendedScanAction extends ToggleAction {
    private final SVNRevisionGraph graph;

    public EnableExtendedScanAction(SVNRevisionGraph graph) {
        super("Scan all current branches/tags");
        this.graph = graph;
    }

    @Override
    public void update(AnActionEvent e) {
        super.update(e);
        e.getPresentation().setEnabled(!graph.isRefreshInProgress());
    }

    @Override
    public boolean isSelected(AnActionEvent e) {
        return graph.isExtendedScanEnabled();
    }

    @Override
    public void setSelected(AnActionEvent e, boolean state) {
        graph.setExtendedScanEnabled(state);
    }
}
